package com.example.administrator.androidui8;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Activity02 extends AppCompatActivity {
    TextView mTvMessage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_02);
        mTvMessage = findViewById(R.id.tv_message);
        try {
            FileInputStream fis = openFileInput("data.txt");
            byte[] buffer = new byte[fis.available()];
            fis.read(buffer);
            fis.close();
            String message = new String(buffer);
            mTvMessage.setText(message);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
